namespace PickGold.Charting
{
    using System;
    using System.ComponentModel;
    using System.Globalization;

    internal class MapAreaCoordinatesConverter : ArrayConverter
    {
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
        }

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string str = value as string;
            if (str == null)
            {
                return base.ConvertFrom(context, culture, value);
            }
            string[] strArray = str.Split(new char[] { ',' });
            float[] numArray = new float[strArray.Length];
            for (int i = 0; i < strArray.Length; i++)
            {
                numArray[i] = float.Parse(strArray[i], CultureInfo.CurrentCulture);
            }
            return numArray;
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof(string))
            {
                return base.ConvertTo(context, culture, value, destinationType);
            }
            float[] numArray = (float[]) value;
            string str = "";
            foreach (float num in numArray)
            {
                str = str + num.ToString(CultureInfo.CurrentCulture) + ",";
            }
            return str.TrimEnd(new char[] { ',' });
        }
    }
}

